<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="layui/layui.js"></script>
</head>
<body>

<form id="addCash" lay-filter="addCash"
      class="layui-form layui-form-pane"
      style="margin: 30px auto; display: inline-block;" >
    <div class="layui-form-item" style="text-align: center;">

        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">银行卡号</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="银行卡号" class="layui-input" name="bankId">
        </div>
        <label class="layui-form-label layui-bg-gray" style=" width: 140px;margin-left: 35px;">账户名称</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required" name="accountName"
                   autocomplete="off" placeholder="账户名称" class="layui-input"
                   onkeyup="value=value.replace(/[\d]/g,'') "
                   onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))">
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style=" width: 140px;margin-left: 35px;">银行名称</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required" name="bankName"
                   autocomplete="off" placeholder="银行名称" class="layui-input"
                   onkeyup="value=value.replace(/[\d]/g,'') "
                   onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))">
        </div>


        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">存储类型</label>
        <div class="layui-input-inline">
        <select name="stockpileType">
            <option placeholder="请选择存款类型" value=""></option>
            <option value="1">活期</option>
            <option value="2">定期</option>
        </select>
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">卡号利率</label>
        <div class="layui-input-inline">
            <input type="number" lay-verify="required"
                   autocomplete="off" placeholder="卡号利率" class="layui-input" name="cardRetes">
        </div>


        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">计息时间</label>
        <div class="layui-input-inline">
            <select name="bearingTime">
                <option value="" placeholder="请选择计息期间"></option>
                <option value="1">360天</option>
                <option value="2">365天</option>
                <option value="3">366天</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">开户时间</label>
        <div class="layui-input-inline">
            <input type="date" lay-verify="required"
                   autocomplete="off" placeholder="开户时间" class="layui-input" name="openTime">
        </div>


        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">结束时间</label>
        <div class="layui-input-inline">
            <input type="date" lay-verify="required"
                   autocomplete="off" placeholder="结束时间" class="layui-input" name="endTime">
        </div>
    </div>
    <br>
    <div class="layui-inline layui-show-xs-block">
        <label class="layui-form-label layui-bg-gray"
               style=" width: 130px; height: 100px; line-height: 81px; margin-left: 100px">备注</label>
        <div class="layui-inline layui-show-xs-block">
                <textarea name="cashRemark" required placeholder="备注" class="layui-textarea"
                          style="width: 467px"></textarea>
        </div>
    </div>
    <div class="layui-form-item" style="position: absolute;left: 28%; bottom: 20px">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addCash"><i class="layui-icon">&#x1005;</i>添加</button>
            <button type="reset" class="layui-btn layui-btn-primary"> <i class="layui-icon">&#x1006;</i>取消</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    layui.use('form',function (){
        var form = layui.form;
        var $ = layui.jquery;

        form.on('submit(addCash)',function(obj){
            console.log(obj.field);
            $.ajax({
                url:"insertCash",
                type:"get",
                data:obj.field,
                dataType:"text",
                contentType:"application/x-www-form-urlencoded",//内容类型  form 表单的
                success:function(msg){
                    if(msg==="ok"){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>